package com.cskaoyan.day12;

import java.util.Random;
import java.util.Scanner;

public class GuestTest {
    public static void main(String[] args) {
        Random random = new Random();
        int numberToGuess = random.nextInt(100) + 1; // 生成1~100之间的随机整数
        int guess;
        Scanner scanner = new Scanner(System.in);
        do {
            System.out.print("请输入猜测的数字（1~100）：");
            guess = scanner.nextInt();

            if (guess > numberToGuess) {
                System.out.println("猜测的数字太大了！");
            } else if (guess < numberToGuess) {
                System.out.println("猜测的数字太小了！");
            }
        } while (guess != numberToGuess);

        System.out.println("恭喜你，猜对了！");
    }
}

